Re: [SQL] Can I prevent my sequence to increment if an insert is rejected?

Поиск
Список
Период
Сортировка
От Herouth Maoz
Тема Re: [SQL] Can I prevent my sequence to increment if an insert is rejected?
Дата
Msg-id l03130300b3bb3fa2d669@[147.233.159.109]
обсуждение исходный текст
Ответ на Can I prevent my sequence to increment if an insert is rejected?  (Frederic De Leersnijder <frederic.de.leersnijder@pandora.be>)
Список pgsql-sql
At 19:54 +0300 on 20/07/1999, Frederic De Leersnijder wrote:


> Hi,
>
> when I try to insert a record and it curses with fields with a unique
> key on them my sequence I use for my primary key does increment. How can
> I prevent this from happening?

You can't. The point of sequences is that they ensure you of unique values,
but they DO NOT ensure you of gap-free values. This allows sequences to be
used momentarily, without being locked for the duration of a transaction,
thus allowing many users to get values with minimal contention.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




В списке pgsql-sql по дате отправления:

Предыдущее
От: "Jonathan davis"
Дата:
Сообщение: how to add users in group
Следующее
От: Chris Bitmead
Дата:
Сообщение: Re: [SQL] Can I prevent my sequence to increment if an insert isrejected?